#!/usr/bin/env python3
import sys

positions = list(map(int, input().split(',')))
print(positions)

min_dist = sys.maxsize
index = -1
# quadratic is good enough
for i, crab in enumerate(positions):
    dist = sum([ abs(crab - other_crab) for other_crab in positions ])
    if dist < min_dist:
        min_dist = dist
        index = i
    print('for crab', crab, 'at', positions[i], 'dist of others is', dist)

print('optimal position is that of crab', index, 'at', positions[index], 'with an expenditure of', min_dist)
